/*
 * @Author: shengduiliang 1107722390@qq.com
 * @Date: 2024-05-04 19:13:07
 * @LastEditors: shengduiliang 1107722390@qq.com
 * @LastEditTime: 2024-05-04 19:35:43
 * @FilePath: /treasure/src/ui-components/checkbox/index.tsx
 * @Description: checkbox组件
 */
import { View } from "@tarojs/components"
import classNames from "classnames"
import './index.scss'

interface CheckboxProps {
  checked: boolean
  label: string
  onChange: (checked: boolean) => void
  className?: string
}

const Checkbox = ({ checked, label, onChange, className } : CheckboxProps ) => {
  return (
    <View className={classNames('checkbox-view row-start-center', className)} onClick={() => onChange(!checked)}>
      <View
        className={classNames({
          'checkbox': true,
          'checked': checked,
        })}
      />
      <View className='checkbox-label text-primary ml-medium'>{label}</View>
    </View>

  )
}

export default Checkbox